from django.contrib import admin
from .models import User, Room, Booking, Amenity, RoomAmenity, Contact, Customer, Bill, Feedback


@admin.register(User)
class UserAdmin(admin.ModelAdmin):
    list_display = ['username', 'email', 'role', 'phone', 'last_login']
    list_filter = ['role']
    search_fields = ['username', 'email', 'phone']


@admin.register(Room)
class RoomAdmin(admin.ModelAdmin):
    list_display = ['room_number', 'name', 'room_type', 'price', 'capacity', 'status', 'count']
    list_filter = ['room_type', 'status']
    search_fields = ['room_number', 'name']


@admin.register(Booking)
class BookingAdmin(admin.ModelAdmin):
    list_display = ['id', 'guest_name', 'room', 'check_in', 'check_out', 'status', 'total_price']
    list_filter = ['status', 'check_in']
    search_fields = ['guest_name', 'guest_phone', 'guest_email']


@admin.register(Amenity)
class AmenityAdmin(admin.ModelAdmin):
    list_display = ['name', 'category']
    list_filter = ['category']


@admin.register(Contact)
class ContactAdmin(admin.ModelAdmin):
    list_display = ['name', 'email', 'subject', 'submitted_at']
    list_filter = ['submitted_at']
    search_fields = ['name', 'email', 'subject']


@admin.register(Customer)
class CustomerAdmin(admin.ModelAdmin):
    list_display = ['name', 'phone', 'email', 'member_level', 'total_stays', 'total_spent']
    list_filter = ['member_level']
    search_fields = ['name', 'phone', 'email']


@admin.register(Bill)
class BillAdmin(admin.ModelAdmin):
    list_display = ['id', 'booking', 'amount', 'status', 'paid_at']
    list_filter = ['status']


@admin.register(Feedback)
class FeedbackAdmin(admin.ModelAdmin):
    list_display = ['title', 'user', 'status', 'created_at']
    list_filter = ['status', 'created_at']
    search_fields = ['title', 'description']
